#include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>

__global__ void helloWorld(char*);

int main(int argc, char** argv)
{
	int i;

	char str[] = "Hello World!";

	for(i = 0; i < 12; i++)
		str[i] -= i;

	char* d_str;

	size_t size = sizeof(str);

	cudaMalloc((void**)&d_str, size);

	cudaMemcpy(d_str, str, size, cudaMemcpyHostToDevice);

	dim3 dimGrid(2);
	dim3 dimBlock(5);

	helloWorld<<<dimGrid, dimBlock>>>(d_str);

	cudaMemcpy(str, d_str, size, cudaMemcpyDeviceToHost);

	cudaFree(d_str);

	std::cout << str;

	std::cin.get();

	return 0;
}

__global__ void helloWorld(char* str)
{
	int idx = blockIdx.x * blockDim.x + threadIdx.x;

	str[idx] += idx;
}